<?php
include_once "config_db.php";

$database = 'mymap';

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");

mysql_query("SET NAMES 'utf8'");

function getType_Administrative($locality_level) {

	$table = 'administrative_map';
	$result = mysql_query("SELECT id, name
                            FROM {$table} where locality_level = ".$locality_level);
	return $result;
}
function getSegment() {

	$table = 'topo_segment';
	$result = mysql_query("SELECT id, name_segment
                            FROM {$table}");
	return $result;
}
function getLastID($table_input) {
	
	$result = mysql_query("SELECT id FROM {$table_input}");
	$id = null;
	if(mysql_num_rows($result) == 0) {
		$id = 1;
	} else {
		while($data = mysql_fetch_array($result)) {
			$id = $data["id"];
		}	
	}
	return $id;
}
?>